<?php
include('config.php');
include(lib_path.'/msg.php');
include(lib_path.'/common.fun.php');

$db = new db($db_config[1], $db_config[2], $db_config[0], $db_config[3]);
$dis_data_msg = array();
$php_s_msg = new msg(DOWN_S_MSG_ID, false);
$php_m_msg = new msg(DOWN_M_MSG_ID, false);

/*
$users[$fd] = array(uid, map_id, process id, login in time)
*/
$users = array();
/*
$maps2pids = array(
	mapid => array(
		array(pid, total user numbers),
		array(pid, total user numbers)
	)
);
*/
$maps2pids = array();

while(1)
{
	$data_flag = false;

	$data = $data_msg->receive(true, $fd);
	if($data)
	{
		$data_flag = true;
		if(!isset($users[$fd])) $users[$fd] = array(0,0,0,0);
		if($users[$fd][0]==0)
		{
			$login_reg_msg->send($data, $fd);
		}else{
			$dis_data_msg
		}
	}
	if(!$data_flag) usleep(5000);
}

function startMapProcess($map_id)
{
	
}